import { createRouter, createWebHashHistory } from "vue-router";
import Index from "@/pages/frontend/index.vue"
import Login from "@/pages/admin/login.vue";
import AdminIndex from '@/pages/admin/index.vue'
import Admin from "@/layouts/admin/admin.vue";
import AdminArticleList from '@/pages/admin/article-list.vue'
import AdminCategoryList from '@/pages/admin/category-list.vue'
import AdminTagList from '@/pages/admin/tag-list.vue'
import AdminBlogSetting from '@/pages/admin/blog-settings.vue'
import AdminWikiList from "@/pages/admin/wiki-list.vue";
import AdminCommentList from "@/pages/admin/comment-list.vue";
import ArchiveList from "@/pages/frontend/archive-list.vue";
import CategoryList from "@/pages/frontend/category-list.vue";
import CategoryArticleList from "@/pages/frontend/category-article-list.vue";
import TagList from "@/pages/frontend/tag-list.vue";
import TagArticleList from "@/pages/frontend/tag-article-list.vue";
import ArticleDetail from "@/pages/frontend/article-detail.vue";
import WikiList from '@/pages/frontend/wiki-list.vue'
import NotFound from '@/pages/frontend/404.vue'
import WikiDetail from '@/pages/frontend/wiki-detail.vue'

const router = createRouter({
    history: createWebHashHistory(),
    routes: [
        {
            path: '/',
            component: Index,
            meta: {
                title: 'KnowledgeHub首页'
            }
        },
        {
            path: '/login',
            component: Login,
            meta: {
                title: 'KnowledgeHub 登录页'
            }
        },
        {
            path: '/archive/list',
            component: ArchiveList,
            meta: {
                title: 'KnowledgeHub 归档页'
            }
        },
        {
            path: '/category/list', // 分类页
            component: CategoryList,
            meta: { // meta 信息
                title: 'KnowledgeHub 分类页'
            }
        },
        {
            path: '/category/article/list', // 分类文章页
            component: CategoryArticleList,
            meta: { // meta 信息
                title: 'KnowledgeHub 分类文章页'
            }
        },
        {
            path: '/tag/list', // 标签列表页
            component: TagList,
            meta: { // meta 信息
                title: 'KnowledgeHub 标签列表页'
            }
        },
        {
            path: '/tag/article/list', // 标签列表页
            component: TagArticleList,
            meta: { // meta 信息
                title: 'KnowledgeHub 标签文章页'
            }
        },
        {
            path: '/article/:articleId', // 文章详情页
            component: ArticleDetail,
            meta: { // meta 信息
                title: 'KnowledgeHub 详情页'
            }
        },
        {
            path: '/wiki/list', // 知识库
            component: WikiList,
            meta: {
                title: '知识库'
            }
        },
        {
            path: '/wiki/:wikiId', // 知识库详情页
            component: WikiDetail,
            meta: {
                title: '知识库详情'
            }
        },
        {
            path: "/admin", // 后台首页
            component: Admin, // 对应 admin.vue 布局文件
            // 使用到 admin.vue 布局的，都需要放置在其子路由下面
            children: [
                {
                    path: "/admin/index",
                    component: AdminIndex,
                    meta: {
                        title: '仪表盘'
                    }
                },
                {
                    path: "/admin/article/list",
                    component: AdminArticleList,
                    meta: {
                        title: '文章管理'
                    }
                },
                {
                    path: "/admin/category/list",
                    component: AdminCategoryList,
                    meta: {
                        title: '分类管理'
                    }
                },
                {
                    path: "/admin/tag/list",
                    component: AdminTagList,
                    meta: {
                        title: '标签管理'
                    }
                },
                {
                    path: "/admin/blog/setting",
                    component: AdminBlogSetting,
                    meta: {
                        title: '博客设置'
                    }
                },
                {
                    path: "/admin/wiki/list",
                    component: AdminWikiList,
                    meta: {
                        title: '知识库管理'
                    }
                },
                {
                    path: "/admin/comment/list",
                    component: AdminCommentList,
                    meta: {
                        title: '评论管理'
                    }
                }
            ]
            
        },
        {
            path: '/:pathMatch(.*)*',
            name: 'NotFound',
            component: NotFound,
            meta: {
                title: '404 页'
            }
        },
    ],
    // 每次切换路由后，页面滚动到顶部
    scrollBehavior() {
        return { top: 0 }
    }
})
export default router